package com.yy.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yy.entity.Vehicle;
import com.yy.mapper.VehicleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VehicleService extends ServiceImpl<VehicleMapper, Vehicle> {
    VehicleMapper mapper;
    @Autowired
    public VehicleService(VehicleMapper mapper) {
        this.mapper = mapper;
    }
    public List<Vehicle> getAll(){
        List<Vehicle> results=mapper.getAll();
        return results;
    }

    public Vehicle getById(Long id) {
        Vehicle entity=mapper.getById(id);
        return entity;
    }

    public boolean insert(Vehicle entity) {
        boolean result=mapper.insert(entity)>0?true:false;
        return result;
    }

    public boolean update(Vehicle entity) {
        boolean result=mapper.update(entity)>0?true:false;
        return result;
    }

    public boolean delete(Long id) {
        boolean result=mapper.deleteById(id)>0?true:false;
        return result;
    }
}